package wenqi.housemediator;

public class ConcreteMediator{
    RentHouse [] rentHouses;
    BegRentHouse [] begRentHouses;
    public void registerRentHouse(RentHouse [] rentHouses){
        this.rentHouses=rentHouses;
    }
    public void registerBegRentHouse(BegRentHouse [] begRentHouses){
        this.begRentHouses=begRentHouses;
    }
    public void deliverMess(Colleague colleague,String mess){
        if(colleague instanceof RentHouse){
            for(int i=0;i<begRentHouses.length;i++){
                begRentHouses[i].receiverMess(colleague.getName()+mess);
            }
        }
        else if(colleague instanceof BegRentHouse){
            for (int i = 0; i < rentHouses.length; i++) {
                rentHouses[i].receiverMess(colleague.getName()+mess);
            }
        }
    }
}
